package com.powernode.reggie.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: MybatisPlus 分页插件配置类
 * @author: www
 * @time: 2023/3/7 14:49
 */
@Configuration  //声明为配置类，以便spring扫描到，读取配置
public class MybatisPlusConfig {

    @Bean  // 让spring管理
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        // 1、创建MP的拦截器容器
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        // 2、MP拦截器容器中添加分页拦截器
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        // 3、返回拦截器容器
        return mybatisPlusInterceptor;
    }
}
